<template>
  <div class="main">

    <!--搜索部分-->
    <div class="user-search-container">



      <el-form ref="params" :inline="true" v-show="true" label-width="68px">

        <el-form-item label="用户编号" prop="username">
          <el-input v-model="params.username" placeholder="请输入用户编号" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery" />
        </el-form-item>

        <el-form-item label="订单编号" prop="orderNo">
          <el-input v-model="params.orderNo" placeholder="请输入订单编号" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="订单状态" prop="payStatus">
          <el-select v-model="params.payStatus" placeholder="类型" clearable size="small" class="item-input">
            <el-option v-for="dict in ORDER_STATUS" :key="dict.value" :label="dict.text" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="支付方式" prop="payWayName">
          <el-select v-model="params.payWayName" placeholder="类型" clearable size="small" class="item-input">
            <el-option v-for="dict in PAY_TYPE" :key="dict.value" :label="dict.text" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="订单类型" prop="payTypeNo">
          <el-select v-model="params.payTypeNo" placeholder="类型" clearable size="small" class="item-input">
            <el-option v-for="dict in ORDER_TYPE" :key="dict.value" :label="dict.text" :value="dict.value" />
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="cyan" icon="el-icon-search" size="mini" @click="queryList(true)">搜索</el-button>
        </el-form-item>
      </el-form>

    </div>

    <!--列表部分-->
    <div class="user-list-container">

      <van-divider />

      <el-table v-loading="loading" :data="list">

        <el-table-column label="订单编号" align="center" prop="id"/>
        <el-table-column label="用户编号" align="center" prop="userId"/>
        <el-table-column label="用户名" align="center" prop="fullName"/>
        <el-table-column label="商品名" align="center" prop="productName"/>
        <el-table-column label="交易金额" align="center" prop="orderAmount"/>
        <el-table-column label="交易状态" align="center" prop="payStatus"/>
        <el-table-column label="支付方式" align="center" prop="payWayName"/>
        <el-table-column label="交易类型" align="center" prop="payTypeName"/>
        <el-table-column label="失败原因" align="center" prop="cancelReason"/>
        <el-table-column label="备注" align="center" prop="remark"/>
        <el-table-column label="交易时间" align="center" prop="createTime"/>



        <!--<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">-->
          <!--<template slot-scope="scope">-->
            <!--<el-button size="mini" type="text" icon="el-icon-edit" @click="handleDetail(scope.row)">详情</el-button>-->
          <!--</template>-->
        <!--</el-table-column>-->
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="params.page" :limit.sync="params.limit" @pagination="onLoad" />
    </div>


  </div>
</template>
<script>
  import { orderPage} from '@/api/friend';
  import commentUtil from "@/utils/commentUtil";
  import {ORDER_STATUS, ORDER_TYPE, PAY_TYPE} from "../../../comm/constant";

  export default {


    data() {
      return {
        params:{
          username: null,
          orderNo: null,
          payStatus: null,
          payTypeNo: null,
          payWayName: null,
          limit: 10,
          page: 1,
        },
        ORDER_STATUS: ORDER_STATUS,
        ORDER_TYPE: ORDER_TYPE,
        PAY_TYPE: PAY_TYPE,
        total:0,
        list: [],
        loading: false,
        isLoading: false,
        showPartnerLv: false,
        selUser: null,
        selectUsers: [],
        userPhone: null,

      }
    },
    methods: {
      moveToParent(){},

      queryList(isSearch){//
        if(this.isLoading) return;
        this.isLoading = true;
        if(isSearch)this.params.page = 1;

        orderPage(this.params).then(res => {
          if(res.data.records){
            console.info("数据条数:" + res.data.records.length);
          }
          console.info("数据:" ,res.data);
          this.list = res.data.records;
          this.total = res.data.total;
          this.loading = false;
          this.isLoading = false;
        });
      },
      onClickLeft() {
        this.$router.go(-1);
      },
      onLoad() {
        console.info("加载数据中 第" + this.params.page + "页" )
        this.queryList(false)
      },
      handleDetail(item) {
        this.$router.push({
          path: "/friend/user/detail",
          query: {
            username: item.username,
          }
        });
      },
    },
    mounted() {
      this.onLoad();
    },

  }
</script>
<style scoped>


  .user-search-container, .user-list-container{
    margin: 8px 17px;
  }
  .user-search-container .van-cell{
    margin: 8px 0px;
  }

  .user-search-container .van-dropdown-menu{
    height: 40px;
    margin: 8px 0px;
  }
  .user-search-container .van-button{
    height: 85px;
    width: 100px;
    background-color: #eeeeee;
    margin: 8px 0px;
  }
  .user-search-container .van-field, .user-search-container .van-cell{
    border: 1px solid #eeeeee;
  }
</style>
